public class Solution963 {
    public double minAreaFreeRect(int[][] points) {
        double ans=Double.MAX_VALUE;
        for (int i=0;i<points.length;i++){
            for (int j=i+1;j<points.length;j++){
                for (int k=j+1;k<points.length;k++){
                    for (int l=k+1;l<points.length;l++){
                        ans=Math.min(ans,cal(points,i,j,k,l));
                        ans=Math.min(ans,cal(points,i,j,l,k));
                        ans=Math.min(ans,cal(points,i,k,j,l));
                        ans=Math.min(ans,cal(points,i,k,l,j));
                        ans=Math.min(ans,cal(points,i,l,k,j));
                        ans=Math.min(ans,cal(points,i,l,j,k));
                    }
                }
            }
        }
        return ans==Double.MAX_VALUE?0:ans;
    }

    private double cal(int[][] points, int a, int b, int c, int d) {
        int[] v1=new int[]{points[a][0]-points[b][0],points[a][1]-points[b][1]};
        int[] v2=new int[]{points[c][0]-points[d][0],points[c][1]-points[d][1]};
        if (v1[0]*v2[1]!=v1[1]*v2[0]){
            return Double.MAX_VALUE;
        }
        if (v1[0]*v1[0]+v1[1]*v1[1]!=v2[0]*v2[0]+v2[1]*v2[1]){
            return Double.MAX_VALUE;
        }
        int[] v3=new int[]{points[a][0]-points[c][0],points[a][1]-points[c][1]};
        int[] v4=new int[]{points[b][0]-points[d][0],points[b][1]-points[d][1]};
        if (v1[0]*v3[0]+v1[1]*v3[1]!=0 || v2[0]*v4[0]+v2[1]*v4[1]!=0){
            return Double.MAX_VALUE;
        }
        return Math.sqrt(v1[0]*v1[0]+v1[1]*v1[1])*Math.sqrt(v3[0]*v3[0]+v3[1]*v3[1]);
    }

    public static void main(String[] args) {
        System.out.println(new Solution963().minAreaFreeRect(new int[][]{{0,2},{0,1},{3,3},{1,0},{2,3},{1,2},{1,3}}));
    }
}
